<?php
class TagAction extends BaseAction{
	
	function index(){
		$tagname = t($_POST['tagname']);
		if(!empty($tagname)){			
			$map['tagname'] = array('like', $tagname);
		}		
		
		$list = M('x_tag')->where($map)->field("tagid, tagname, isShow")->order("tagid desc")->findpage(50);
		foreach ($list['data'] as $k=>$v){
			if(empty($v['tagname'])){
				unset($list['data'][$k]);
			}
		}
		$this->assign('list', $list);
				
		$this->display();
	}
	
	function show(){
		$map['tagid'] = intval($_GET['tagid']);
		
		$res = M('x_tag')->where($map)->setField('isShow', 1);
		if($res){
			$this->success('操作成功');
		}else{
			$this->error('操作失败');
		}
	}
	
	function unshow(){
		$map['tagid'] = intval($_GET['tagid']);
		
		$res = M('x_tag')->where($map)->setField('isShow', 0);
		if($res){
			$this->success('操作成功');
		}else{
			$this->error('操作失败');
		}
	}	
}
?>